/*
 * @Author: Jimmy
 * @LastModifiedBy: Jimmy
 * @Date: 2024-06-22 17:34:53
 * @LastEditTime: 2024-09-07 20:44:00
 * @FilePath: /nest_study/server/src/modules/system/dept/dept.controller.ts
 */
import { Controller, Get, Post, Body, Request, Delete, Put, Query } from '@nestjs/common';
import { DeptService } from './dept.service';
import { CreateDeptDto, DeleteDeptDto, QueryDeptDto, UpdateDeptDto } from './dto/index.dto';
import { ApiBody, ApiOperation, ApiTags } from '@nestjs/swagger';

@ApiTags('部门管理')
@Controller('system/dept')
export class DeptController {
  constructor(private readonly deptService: DeptService) { }

  @ApiOperation({
    summary: '查询部门列表'
  })
  @ApiBody({
    type: QueryDeptDto,
    required: true
  })
  @Get("/list")
  findTree(@Query() query: QueryDeptDto) {
    return this.deptService.findTree(query);
  }

  @ApiOperation({
    summary: '创建部门'
  })
  @ApiBody({
    type: CreateDeptDto,
    required: true
  })
  @Post("/create")
  create(@Body() createDeptDto: CreateDeptDto, @Request() req) {
    return this.deptService.create(createDeptDto);
  }

  @ApiOperation({
    summary: '更新部门信息'
  })
  @ApiBody({
    type: UpdateDeptDto,
    required: true
  })
  @Put('/update')
  update(@Body() updateDeptDto: UpdateDeptDto, @Request() req) {
    return this.deptService.update(updateDeptDto);
  }

  @ApiOperation({
    summary: '删除部门信息'
  })
  @ApiBody({
    type: DeleteDeptDto,
    required: true
  })
  @Delete('/delete')
  remove(@Body() deptInfo: DeleteDeptDto) {
    return this.deptService.remove(deptInfo);
  }

}
